<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.EditTimeLogTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form>
                <h:panelGrid columns="2">
                    <h:outputLabel value="#{bundle.EditTimeLogLabel_project}" for="project" />
                    <h:selectOneMenu id="project" value="#{timeLogController.selected.project}" title="#{bundle.EditTimeLogTitle_project}" required="true" requiredMessage="#{bundle.EditTimeLogRequiredMessage_project}">
                        <f:selectItems value="#{projectsController.itemsAvailableSelectOne}"/>
                    </h:selectOneMenu>
                    
                    <h:outputLabel value="#{bundle.EditTimeLogLabel_task}" for="task" />
                    <h:inputText id="task" value="#{timeLogController.selected.task}" title="#{bundle.EditTimeLogTitle_task}" required="true" requiredMessage="#{bundle.EditTimeLogRequiredMessage_task}"/>

                    <h:outputLabel value="#{bundle.EditTimeLogLabel_activity}" for="activity" />
                    <h:selectOneMenu id="activity" value="#{timeLogController.selected.activity}" title="#{bundle.EditTimeLogTitle_activity}" required="true" requiredMessage="#{bundle.EditTimeLogRequiredMessage_activity}">
                        <f:selectItems value="#{timeLogController.activities}"/>
                    </h:selectOneMenu>
                    
                    
                    <h:outputLabel value="#{bundle.EditTimeLogLabel_workedHours}" for="workedHours" />
                    <h:inputText id="workedHours" value="#{timeLogController.selected.workedHours}" title="#{bundle.EditTimeLogTitle_workedHours}" required="true" requiredMessage="#{bundle.EditTimeLogRequiredMessage_workedHours}"/>

                    <h:outputLabel value="#{bundle.CreateTimeLogLabel_date}" for="date" />
                    <p:calendar value="#{timeLogController.selected.date}" id="date" showOn="button" />

                    <c:if test="${type=='admin'}">
                    <h:outputLabel value="#{bundle.EditTimeLogLabel_emplyee}" for="emplyee" />
                    <h:selectOneMenu id="emplyee" value="#{timeLogController.selected.emplyee}" title="#{bundle.EditTimeLogTitle_emplyee}" required="true" requiredMessage="#{bundle.EditTimeLogRequiredMessage_emplyee}">
                        <f:selectItems value="#{employeesController.itemsAvailableSelectOne}"/>
                    </h:selectOneMenu>
                    </c:if>

                </h:panelGrid>
                <h:commandButton action="#{timeLogController.update}" type="submit" value="#{bundle.EditTimeLogSaveLink}"/>
                <h:commandButton action="View" value="#{bundle.EditTimeLogViewLink}" type="submit" immediate="true"/>
            </h:form>

            <h:form>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <h:commandButton rendered="${type=='admin'}" action="#{timeLogController.prepareList}" type="submit" value="#{bundle.EditTimeLogShowAllLink}" immediate="true"/>
                <h:commandButton rendered="${type=='user'}" type="submit" action="#{timeLogController.listUserTimeLog}" value="#{bundle.EditTimeLogShowAllLink}"/>
                <h:button rendered="${type=='admin'}" value="Back to Home" outcome="/index" />
                <h:button rendered="${type=='user'}" value="Back to Home" outcome="/userhome"/>
            </h:form>
        </ui:define>
    </ui:composition>
</html>
